package com.project.livetv.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by li on 2016/5/10.
 */
public class MyPageAdapter extends PagerAdapter {
    private List<View> listviews;
    public MyPageAdapter(List<View> listviews){
        this.listviews=listviews;
    }
    @Override
    public int getCount() {
        return listviews==null?0:listviews.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view==object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(listviews.get(position));
        return listviews.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
      //  super.destroyItem(container, position, object);
        container.removeView(listviews.get(position));
    }
}
